package com.simon.hse.activity.safe.jobticket.commonly;

import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.simon.hse.R;
import com.simon.hse.activity.BaseActivity;
import com.simon.hse.adapter.CommonEmptyAdapter;
import com.simon.hse.adapter.CommonViewHolder;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

/**
 * 机械移动式起重机外观检查表内容
 */
@SuppressWarnings("all")
@ContentView(R.layout.activity_commonly_qizhongji_detail)
public class CommonlyQizhongjiDetailActivity extends BaseActivity {
    @ViewInject(R.id.tv_common_title)
    TextView mTv_common_title;

    @ViewInject(R.id.iv_common_right)
    ImageView mIv_common_right;

    @ViewInject(R.id.recyclerview_xzzz)
    RecyclerView mRecyclerview_xzzz;

    @ViewInject(R.id.recyclerview_qzj)
    RecyclerView mRecyclerview_qzj;

    private boolean isShowMore = false;// 是否展示更多筛选框

    @ViewInject(R.id.ll_message_more)
    LinearLayout mLl_message_more;

    List<String> mListXzzz = new ArrayList<>();

    List<String> mListQzj = new ArrayList<>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mTv_common_title.setText("机械移动式起重机外观检查表");
        mIv_common_right.setVisibility(View.GONE);
        initListDataXzzz();
        initListDataQzj();
        initXzzz();
        initQzj();
    }

    @Event(value = {R.id.iv_common_left, R.id.tv_train_record_confirm, R.id.tv_train_record_cancel, R.id.ll_msg_more, R.id.tv_message_more_reset, R.id.tv_message_more_confirm})
    private void clickButton(View view) {
        switch (view.getId()) {
            case R.id.iv_common_left:
                finish();
            case R.id.tv_train_record_confirm:
                finish();
                break;
            case R.id.tv_train_record_cancel:
                finish();
                break;
            case R.id.ll_msg_more:
                if (isShowMore) {
                    mLl_message_more.setVisibility(View.GONE);
                } else {
                    mLl_message_more.setVisibility(View.VISIBLE);
                }
                isShowMore = !isShowMore;
                break;
            case R.id.tv_message_more_reset:
                mLl_message_more.setVisibility(View.GONE);
                isShowMore = !isShowMore;
                break;
            case R.id.tv_message_more_confirm:
                mLl_message_more.setVisibility(View.GONE);
                isShowMore = !isShowMore;
                break;
        }
    }

    /**
     * 行走装置
     */
    private void initXzzz() {
        LinearLayoutManager llm = new LinearLayoutManager(CommonlyQizhongjiDetailActivity.this);
        mRecyclerview_xzzz.setLayoutManager(llm);
        // 如果Item够简单，高度是确定的，打开FixSize将提高性能
        mRecyclerview_xzzz.setHasFixedSize(true);
        // 设置Item默认动画，加也行，不加也行
        mRecyclerview_xzzz.setItemAnimator(new DefaultItemAnimator());
        mRecyclerview_xzzz.setNestedScrollingEnabled(false);

        CommonEmptyAdapter mCommonEmptyAdapter = new CommonEmptyAdapter(CommonlyQizhongjiDetailActivity.this, R.layout.layout_commonly_qizhongji_detail_item, mListXzzz);
        mCommonEmptyAdapter.setItemDataListener(new CommonEmptyAdapter.ItemDataListener<String>() {
            @Override
            public void setItemData(CommonViewHolder holder, String dataBean) {
                TextView tv_name = holder.getView(R.id.tv_name);
                tv_name.setText(mListXzzz.get(holder.getLayoutPosition()));
            }
        });

        mCommonEmptyAdapter.setOnItemEmptyClickListener(new CommonEmptyAdapter.OnItemEmptyClickListener() {
            @Override
            public void setOnEmptyClickListener() {

            }

            @Override
            public void setOnItemClickListener(View view, int position) {

            }

            @Override
            public void setOnItemLongClickListener(View view, int position) {

            }
        });

        mCommonEmptyAdapter.setHasStableIds(true);
        mRecyclerview_xzzz.setAdapter(mCommonEmptyAdapter);
    }
    private void initListDataXzzz(){
        mListXzzz.add("1.驾驶室");
        mListXzzz.add("窗户");
        mListXzzz.add("踏板");
        mListXzzz.add("转向");
        mListXzzz.add("喇叭");
        mListXzzz.add("2.刹车操作检查");
        mListXzzz.add("3.倒车报警器");
        mListXzzz.add("4.车轮");
        mListXzzz.add("轮胎（裂缝，腐蚀）");
        mListXzzz.add("轮毂（裂缝）");
        mListXzzz.add("螺栓（是否完整、拧紧）");
        mListXzzz.add("5.支腿");
        mListXzzz.add("垫板（检查裂缝和变形）");
        mListXzzz.add("6.驱动机构操作检查");
        mListXzzz.add("7.灭火器");
    }

    /**
     * 起重机
     */
    private void initQzj() {
        LinearLayoutManager llm = new LinearLayoutManager(CommonlyQizhongjiDetailActivity.this);
        mRecyclerview_qzj.setLayoutManager(llm);
        // 如果Item够简单，高度是确定的，打开FixSize将提高性能
        mRecyclerview_qzj.setHasFixedSize(true);
        // 设置Item默认动画，加也行，不加也行
        mRecyclerview_qzj.setItemAnimator(new DefaultItemAnimator());
        mRecyclerview_qzj.setNestedScrollingEnabled(false);

        CommonEmptyAdapter mCommonEmptyAdapter = new CommonEmptyAdapter(CommonlyQizhongjiDetailActivity.this, R.layout.layout_commonly_qizhongji_detail_item, mListQzj);
        mCommonEmptyAdapter.setItemDataListener(new CommonEmptyAdapter.ItemDataListener<String>() {
            @Override
            public void setItemData(CommonViewHolder holder, String dataBean) {
                TextView tv_name = holder.getView(R.id.tv_name);
                tv_name.setText(mListQzj.get(holder.getLayoutPosition()));
            }
        });

        mCommonEmptyAdapter.setOnItemEmptyClickListener(new CommonEmptyAdapter.OnItemEmptyClickListener() {
            @Override
            public void setOnEmptyClickListener() {

            }

            @Override
            public void setOnItemClickListener(View view, int position) {

            }

            @Override
            public void setOnItemLongClickListener(View view, int position) {

            }
        });

        mCommonEmptyAdapter.setHasStableIds(true);
        mRecyclerview_qzj.setAdapter(mCommonEmptyAdapter);
    }
    private void initListDataQzj(){
        mListQzj.add("1.刹车和离合器检查：");
        mListQzj.add("1)绳鼓的刹车鼓与刹带间隙检查");
        mListQzj.add("2)不均匀的磨损");
        mListQzj.add("3)刹车板上是否有油脂");
        mListQzj.add("4)连接装置");
        mListQzj.add("2.导向滑轮（检查裂缝，润滑）");
        mListQzj.add("3.滑轮组（检查裂缝，润滑）");
        mListQzj.add("4.A型架滑轮（检查裂缝、润滑）");
        mListQzj.add("5.吊钩（检查裂缝，变形，安全销、舌片）");
        mListQzj.add("6.辅钩吊钩（检查裂缝，变形，安全销）");
        mListQzj.add("7.起重臂（检查钢索是否弯曲、变形）");
        mListQzj.add("8.钢丝绳导辊（自由转动）");
        mListQzj.add("9.导辊（自由转动）");
        mListQzj.add("10.前臂钢缆（端部不得有断丝）");
        mListQzj.add("11.主臂起降钢丝绳");
        mListQzj.add("12.主辅钩钢丝绳");
        mListQzj.add("1)直径是否满足负荷要求，图表和滑轮");
        mListQzj.add("2)正确地连接");
        mListQzj.add("楔形插座尺寸");
        mListQzj.add("钢丝绳夹不得夹到钢丝绳长端");
        mListQzj.add("3)无绞扭或永久性弯曲");
        mListQzj.add("4)个绳节距上的断丝不超过6个，或一个绳节距的一股上不超过3个断丝");
        mListQzj.add("5)当起重臂伸长到最大长度，臂角为最大，吊钩在最低工作点时，绳鼓上的钢丝绳至少有三圈。");
        mListQzj.add("13.操作室");
        mListQzj.add("窗户");
        mListQzj.add("喇叭");
        mListQzj.add("通道");
        mListQzj.add("载荷表");
        mListQzj.add("起重机司机手册");
        mListQzj.add("14.灭火器");
        mListQzj.add("15.转动部件防护罩");
        mListQzj.add("16.平台和走道的防滑表面");
    }
}
